package com.myproject.jdbc;

import java.sql.*;

public class Jdbc {

    public static void main(String[] args) {

        Connection connection = null;
        try {
            connection = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/giftcptdb?characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false","root","root123");
        } catch (SQLException e) {
            e.printStackTrace();
        }

        String sql = "select version()";
        Statement statement = null;
        try {
            statement = connection.createStatement();
            ResultSet rs = statement.executeQuery(sql);
            while (rs.next()){
                String version = rs.getString("version()");
                System.out.println("mysql version: "+version);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
